/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 * @flow
 */

import React, {Component} from 'react';
import {
    AppRegistry,
    StyleSheet,
    Text,
    View,
    Image,
    ScrollView,
    TouchableOpacity
} from 'react-native';

import GCStyle from '../../Model/Global/GCStyle';
import SelectorDate from '../../Model/Component/SelectorDate';

export default class Header extends Component {
    constructor(props) {
        super(props);
        this.state = {

        }
    }

    componentDidMount() {

    }
    onSelectAction(index, name) {
        if (name === '今天') {
            this.props.onSetlectAction('today');
        } else if (name === '昨日') {
            this.props.onSetlectAction('yesterday');
        } else if (name === '最近7日') {
            this.props.onSetlectAction('week');
        }
    }

    test(){

    }
    render() {
        var {
            head_data,
            partners
        } = this.props;
        var total_money = '0';
        var order_count = '0';
        var bus_count ='0';
        if(head_data!=null&&head_data.bus_count!=null){
            bus_count=head_data.bus_count;
        }
        if (head_data !== null && head_data.total_money != null) {
            total_money = head_data.total_money;
        }
        if (head_data !== null && head_data.order_count != null) {
            order_count = head_data.order_count;
        }
        return (
            <View style={styles.container}>
                <View>
                    <View style={{flexDirection: 'row'}}>
                        <Text style={[styles.promptTxt, {paddingLeft: 8}]}>合作商:</Text>
                        <Text style={styles.infoTxt}>{partners}</Text>
                    </View>
                    <View style={{marginTop:30, justifyContent: 'space-between', flexDirection: 'row'}}>
                        <View style={[styles.boxView,{borderRightWidth: 1, borderRightColor: GCStyle.GCStyleConst.lineColor}]}>
                            <View style={{flexDirection:'row',alignItems:'center'}}>
                                <Text style={[styles.priceTxt,{marginBottom:4,fontSize: 20}]}>￥</Text>
                                <Text style={[styles.priceTxt,{marginBottom:4}]}>{total_money}</Text>
                            </View>
                            <Text style={styles.prompTitleTxt}>营收</Text>
                        </View>
                        <View style={[styles.boxView,{borderRightWidth: 1, borderRightColor: GCStyle.GCStyleConst.lineColor}]}>   
                            <View style={styles.boxView}>
                                <Text style={[styles.priceTxt,{marginBottom:4}]}>{order_count}</Text>
                                <Text style={styles.prompTitleTxt}>订单</Text>
                            </View>
                        </View>
                        <View style={styles.boxView}>
                            <Text style={[styles.priceTxt,{marginBottom:4}]}>{bus_count}</Text>
                            <Text style={styles.prompTitleTxt}>车辆</Text>
                        </View>

                    </View>
                </View>
                <SelectorDate ref="mySelect" marTop={20} onSelectAction={(index, name)=>this.onSelectAction(index, name)} selectArr={['今天', '昨日', '最近7日']}/>
            </View>
        );
    }
}

const styles = StyleSheet.create({
    container: {
        backgroundColor: 'white',
        height: 142,
        width:GCStyle.GCPubWidth,
        paddingLeft: 10,
        paddingRight: 10,
        paddingTop: 25,
        borderBottomWidth: 1,
        borderBottomColor: GCStyle.GCStyleConst.lineColor
    },
    promptTxt: {
        fontSize: 14,
        color: '#000000',
        marginRight: 8,

    },
    boxView: {
        flex:1,
        justifyContent:'center',
        alignItems:'center'
    },
    infoTxt: {
        fontSize: 14,
        color: '#989898'
    },
    priceTxt:{
        fontSize: 25,
        color: GCStyle.GCStyleConst.themeBackColor
    },
    prompTitleTxt:{
        fontSize: 12,
        color:'#000000'
    },
    welcome: {
        fontSize: 20,
        textAlign: 'center',
        margin: 10,
    },
});

